package main

func main() {

}

func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
	adv := 0
	head := &ListNode{}
	p := head
	for l1 != nil || l2 != nil {
		v := adv
		if l1 != nil {
			v += l1.Val
			l1 = l1.Next
		}
		if l2 != nil {
			v += l2.Val
			l2 = l2.Next
		}

		if v > 9 {
			adv = 1
			v = v % 10
		} else {
			adv = 0
		}
		p.Next = &ListNode{Val: v}
		p = p.Next
	}
	if adv != 0 {
		p.Next = &ListNode{Val: adv}
	}
	return head.Next
}

/*

1200
MCC
x/1000 = mM

/100 = 1~3 4~8
*/

func intToRoman(num int) string {
	thousands := []string{"", "M", "MM", "MMM"}
	hundreds := []string{"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}
	tens := []string{"", "X", "XX", "XXX", "XL", "X", "XL", "XLL", "XLL", "XLL"}
	ones := []string{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"}

	return thousands[num/1000] + hundreds[num%1000/100] + tens[num%100/10] + ones[num%10]
}
